<?php

class userRoleModel extends CDBModelBase {
	
	public function getTabelName(){
		return "tbl_base_user_role";
	}

	public function getPKID(){
		return "user_role_id";
	}
	
	protected function getSequence()
	{
		return "USER_ROLE_SEQUENCE";
	}
	
    /**
     * 根据用户ID，删除用户的所有权限
     * @param int user_id
     * @return void
     */
    public function deleteUserRole($userId)
    {
        $params = array(array(":user_id", $userId,PDO::PARAM_INT));
		return $this->db->executeNonQuery("delete from tbl_base_user_role where user_id=:user_id",$params);
    }
	
    
    /**
     * 根据用户ID，查询用户所有角色ID
     * 
     * @param int $uid
     * @return array
     */
    public function selectUserRole($userId)
    {
        $params = array(array(":user_id", $userId,PDO::PARAM_INT));
		return $this->db->executeDataSet("SELECT * from tbl_base_user_role where user_id=:user_id",$params);
    }
    
    
    /**
     * 查询所有用户所对应的角色ID
     * 
     * @return
     */
    public function selectUserRoleId()
    {
        return $this->db->executeDataSet(
        		"select tbu.user_id,tbur.role_id from tbl_base_user tbu left join tbl_base_user_role tbur
 				on tbu.user_id=tbur.user_id where del_flag=0");
        
    }
}



?>